
$(function () {
    var html = [];
    html.push("<div id='headerstyle1'>");
    html.push("<span class=' tab_mune tab_a' id='areaspan'><a href='javascript:void(0)' class='hd-city' id='currentcity'><span id='currentcityname' style='font-size:1.2em; margin-right:10px;'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><i class=\"angle down icon\" style=\"font-size:1.8em; margin:0; position:absolute; top:0.7em; left:2.2em\"></i></a></span>");
    html.push("<span class=' tab_mune tab_b'><div id='searchtext' ><div class=' tab-seacr-bg' style='background: #ff926E;'><i class=\"search icon\" style=\"font-size:1em; margin-right:0.5em;\"></i><input type='search' id='searchvalue' readonly='true' class='tab-text-search' placeholder='搜索商家/商圈/商品'/></div></div></span>");
    html.push("<span class=' tab_mune tab_a'><a id='headertalk' class='hd-ma'><i class=\"outline comment icon\" style=\"font-size:1.2em; margin:0; margin-top:5px;\"></i></p><p style=\"font-size:0.9em\">消息</p></a></span>");
    html.push("</div>");

    $("#header").html(html.join(""));    
})

function plusReady() {
    // 缓存是否有数据
    var cachecity = plus.storage.getItem(storageManager.currentcity);
    if (cachecity) {
        $("#currentcityname").text(JSON.parse(cachecity).name);
    }
    // 城市切换
    $("#header").on("click", "#currentcity", function () {
        var citypage = plus.webview.getWebviewById(pageName.city);
        if (citypage) {
            citypage.show("slide-in-bottom");
        }
        else {
            clicked(pageName.city,false,false,"slide-in-bottom");
        }
    });

    // 搜索    
    $("#header").on("click", "#searchtext", function () {
        clicked("../home/search.html", false, false, "pop-in");
    });

    // 消息
    $("#header").on("click", "#headertalk", function () {
        clicked("../message/message.html", false, false, "pop-in");
    });
}
if (window.plus) {
    plusReady();
} else {
    document.addEventListener('plusready', plusReady, false);
}